MonthDate.getLastDay   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
1
import { lastDayOfMonth, format } from 'date-fns';
2
3
export class MonthDate {
4
  constructor(public readonly year: number, public readonly month: number) {}
5
6
  getFirstDay(): Date {
7
    return new Date(`${this.year}-${String(this.month).padStart(2, '0')}-01`);
8
  }
9
10
  getLastDay(): Date {
11
    const localDate = lastDayOfMonth(this.getFirstDay());
12
    return new Date(format(localDate, 'yyyy-MM-dd'));
13
  }
14
}
15